package dao.hero;


public class Guanghua extends BaseHero {
	private int num;
	private int enemy_att;
	public Guanghua()
    {
       this.name="广华";
       this.ID = 1367;
       this.HP = 830;
       this.maxHP=HP;
       this.ATT = 75;      
       this.DEF = 28;     
       this.DEX = 81;   
       this.blue = 310;
       this.sname1 = "普通攻击";
       this.sname2 = "华软枪神";
       this.sname3 = "乐善好施";
       this.sname4 = "广华的蔑视";
       this.describe_skill1 = "技能详解：普通攻击，造成一定的物理伤害";
       this.describe_skill2 = "技能详解：耗蓝40，号称华软枪神，造成巨大伤害，且带有致残效果（敏捷下降2），但命中率低";
       this.describe_skill3 = "技能详解：耗蓝35，得道者多助，在朋友的帮助下，主动回复血量150+，被动每回合回复血量10";
       this.describe_skill4 = "技能详解：耗蓝150，广华的蔑视，蔑视一切，吓到对手脚抖，3回合内对手攻击力降为0";
       this.describe_hero = "人物介绍：G142舍长大人，乐善好施，经典宅男，此角色若人品好则高爆发，定位为综合型英雄";
       this.myluck= "一般";
       num=99;
       headpath="image\\"+"ghhead.jpg";
       bodypath="image\\"+"ghbody.png";
       //head=Toolkit.getDefaultToolkit().getImage("image\\"+"xlhead.jpg");
       }
	public void attack(int skill, BaseHero enemy) {
		// TODO Auto-generated method stub
		if(skill==1){
			skill1(enemy);
		}else if(skill==2){
			skill2(enemy);
		}else if(skill==3){
			skill3(enemy);
		}else if(skill==4){
			skill4(enemy);
		}
		blue+=18;//自身回蓝能力
		HP+=10;//被动技能回复10
		if(HP>maxHP)//确保回血量不超过最大血量
			HP=maxHP;

		if(num==3)
			enemy.setATT(enemy_att);
		num++;
	}


	public void skill1(BaseHero enemy) {
		// TODO Auto-generated method stub
		blood=true;//掉血
		BaseHero.luck=(int)(Math.random()*10);//运气值随机数
		enemy.setLastHP(enemy.getHP());//重置上一次血量
		if((BaseHero.luck<2||isDodge(enemy))&&!noDodge){
			tip="普通攻击,"+enemy.getName()+"运气太好了，闪开了这次攻击";
		}else if(BaseHero.luck>7){
			enemy.setHP(enemy.getHP()-(ATT*2+BaseHero.luck*6)*(1-enemy.getDEF()/100));
			tip=name+"状态不错，使出了会心一击，造成"+enemy.getName()+(int)(enemy.getLastHP()-enemy.getHP())+"伤害";
		}else {
			enemy.setHP(enemy.getHP()-(this.ATT+BaseHero.luck*4)*(1-enemy.getDEF()/100));
			tip=name+"普通攻击，造成"+enemy.getName()+(int)(enemy.getLastHP()-enemy.getHP())+"伤害";
		}
	}

	public void skill2(BaseHero enemy) {
		// TODO Auto-generated method stub
		blood=true;//掉血
		enemy.setLastHP(enemy.getHP());// 重置上一次血量

		if ((blue - 50) >= 0) {// 是否够蓝
			if (isDodge(enemy) && !noDodge) {
				// 闪避了
				tip = "枪神开枪," + enemy.getName() + "太敏捷了，竟然闪开了这次攻击";
			} else {// 没有闪避
				BaseHero.luck = (int) (Math.random() * 10);// 运气值随机数
				if (BaseHero.luck > 4) {
					enemy.setHP(enemy.getHP() - 280
							* (1 - enemy.getDEF() / 100));
					enemy.setDEX(enemy.getDEX() - 2);// 敏捷下降2
					tip = name + "枪神开枪，造成"
							+ (int) (enemy.getLastHP() - enemy.getHP())
							+ "伤害，且敌人敏捷下降2";
				} else {
					tip = name + "枪神居然开空枪，很是让人怀疑水平!?!?,造成0伤害";
				}
			}

			blue -= 50;
		} else {
			skill1(enemy);
		}
		
	}

	public void skill3(BaseHero enemy) {
		// TODO Auto-generated method stub
		setLastHP(getHP());
		BaseHero.luck=(int)(Math.random()*9);//运气值随机数
		blood=false;//回血
		if((blue-35)>=0){//是否够蓝
			setHP(HP+150+BaseHero.luck*2);
			tip=name+"平时慷慨解囊，有朋友前来帮助，回复血量"+(150+BaseHero.luck*2);
			if(HP>maxHP){//确保回血量不超过最大血量
				HP=maxHP;
				tip+=",已经满血了";
			}
				
			blue-=35;
		}else {
			skill1(enemy);
		}
		
	}

	public void skill4(BaseHero enemy) {
		// TODO Auto-generated method stub
		setLastHP(getHP());
		enemy.setLastHP(enemy.getHP());//重置上一次血量
		blood=true;//掉血
		if((blue-150)>=0){//是否够蓝
			if(num>3)
			   enemy_att=enemy.getATT();
			num=0;
			enemy.setATT(0);
			blue-=150;
			tip=name+"大招！广华的蔑视！！！，对手吓到脚抖，3回合内攻击力将为0";
		}else {
			skill1(enemy);
		}
		
	}
	public boolean isDodge(BaseHero enemy){
		//当前敏捷比敌人高，增加闪避率,否则降低闪避率
		double dodge=enemy.getDEX()*0.3+(enemy.getDEX()-DEX)*0.25;
		System.out.println("当前闪避率"+dodge);
		int rand=(int)(Math.random()*100);//运气值随机数
		if(rand<dodge){
			System.out.println("闪避了"+rand);
			return true;
		}else{
			System.out.println("闪不开"+rand);
			return false;
		}    
	}
}